翻訳と辞書
Words near each other
・ Rules!
・ Ruleta
・ Ruleta (song)
・ Ruleta de la Muerte (1998)
・ Ruleta de la Muerte (1999)
・ Ruleta de la Muerte (2012)
・ Ruleta de la Muerte (2015)
・ Ruletero a toda marcha
・ Rule of thirds
・ Rule of thirds (disambiguation)
・ Rule of thirds (diving)
・ Rule of thirds (military)
・ Rule of three
・ Rule of three (aeronautics)
・ Rule of three (C++ programming)
Rule of three (computer programming)
・ Rule of three (economics)
・ Rule of three (statistics)
・ Rule of Three (Wicca)
・ Rule of three (writing)
・ Rule of thumb
・ Rule of tincture
・ Rule of twelfths
・ Rule of Wen and Jing
・ RULE Project
・ Rule Supreme
・ Rule the School
・ Rule the World
・ Rule utilitarianism
・ Rule Water


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Rule of three (computer programming) : ウィキペディア英語版
Rule of three (computer programming)

Rule of three is a code refactoring rule of thumb to decide when a replicated piece of code should be replaced by a new procedure. It states that the code can be copied once, but that when the same code is used three times, it should be extracted into a new procedure. The rule was introduced by Martin Fowler in ''Refactoring'' and attributed to Don Roberts.
Duplication in programming is a bad practice because it makes the code harder to maintain. However, code refactoring to eliminate duplication also takes time, which might be better spent on other tasks. Triplication has an even higher cost because it makes maintenance harder yet. When the rule encoded in a replicated piece of code changes, whoever maintains the code will have to change it in all places correctly. This process is error-prone and often leads to problems. If the code exists in only one place, then it can be easily changed there. The rule proposes that the cost of maintenance certainly outweighs the cost of refactoring when there are three copies, and may or may not if there are two copies.
This rule is typically only applied to a small number of lines of code, or even single lines of code . For example, if a program calls a function, and then calls it again when it fails, it is acceptable to have two call sites; however, if it is to be called five times before giving up, all of the calls should be replaced with loop containing a single call.
As Charles Petzold puts it, "Three or more? Use a for!"

==See also==

* Copy and paste programming
* Don't repeat yourself (DRY)
* Edsger W. Dijkstra "two or more, use a for"

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Rule of three (computer programming)」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.